package oh.june.kwon.custom;

import oh.june.kwon.util.DrawUtil;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;

public class TabButton extends ButtonField{

	String _text;
	public TabButton(String text){
		_text = text;
	}
	
	protected void layout(int width, int height) {
		setExtent(Math.min(width, getPreferredWidth()), Math.min(height, getPreferredHeight()));
	}

	protected void paint(Graphics graphics) {
		
		if(this.isFocus()){
			int color = DrawUtil.getColor(100, 100, 100);
			XYEdges padding = new XYEdges(10,10,10,10);
			Border border = BorderFactory.createRoundedBorder(padding, color, Border.STYLE_FILLED);
			this.setBorder(border);
			
		}else{
			int color = DrawUtil.getColor(0, 0, 255);
			XYEdges padding = new XYEdges(10,10,10,10);
			Border border = BorderFactory.createRoundedBorder(padding, color, Border.STYLE_FILLED);
			this.setBorder(border);
			
		}
		
		graphics.drawText(_text, 0, 0);
		this.invalidate();
		super.paintBackground(graphics);
	}
	protected boolean navigationClick(int status, int time) {
		fieldChangeNotify(1);
		return true;
	}
	protected boolean navigationMovement(int dx,
            int dy,
            int status,
            int time)
	{
		invalidate();
		return false; 
	}
}
